<template>
	<div class="winingList">
		<x-header title="往期中奖名单" :left-options="{backText:''}" class='whiteHeader'>
		</x-header>
		<scroller :on-infinite="infinites" ref='myScroller'>
			<div class="allList">
				<div class="listItem" v-for='item in allList' @click='gowiningDetail(item.GROUPON_GOODS_ID)'>
					<img :src="item.SERVDETAIL_PHOTO" alt="" />
					<div class="winingMess">
						<h1>{{item.SERV_DETAIL_NAME}}</h1>
						<p>开奖时间：{{item.PRIZE_TIME | filterTimesss}}</p>
						<div class="winingP">一等奖：{{item.PRIZE_USER_PHONE}}<span v-if='item.PRIZE_USER_COUNT>1'> 等{{item.PRIZE_USER_COUNT}}位用户</span></div>
					</div>
				</div>
				<div class="noMoreDate"  v-if='noData2&&allList.length>0'>
	                <div class="noMoreLine"></div>
	                <span>没有更多了哟</span>
	            </div>
			</div>
		</scroller>
	</div>
</template>
<script>
/*往期中奖名单*/
import { XHeader } from 'vux';
import { setCookie, getCookie,reloads,appid,pushStateUrl,iosAdroidWx} from '../../util/commonUtils';
import wx from 'weixin-js-sdk'//微信jssdk
export default {
	name: "winingList",
	// 数据
	data() {

		return {
			userId: '',
			pages:1,
			requestCan:true,
			allList:[],
			noData2:false
		}
	},
	// 计算属性
	computed: {

	},
	// 创建（实例创建完成）
	created() {
		this.userId = getCookie('loginkey');
		if(sessionStorage.getItem('reload')){
	      sessionStorage.removeItem('reload');
	    }else{
	      sessionStorage.setItem('reload',1);
	      pushStateUrl();
	      reloads();
	      return;
	    }
		this.getwiningList();
		this.getConfig();
	},
	// el被创建，并挂载到实例上
	mounted() {

	},
	// 方法（实例中的方法）-----------
	methods: {
		getwiningList(){
			this.requestCan=false;
			this.$fetchPost('/Groupon/getHistoryPrizeRecordList.action',{
				PAGE_NO:this.pages
			}).then(res=>{
	          if(res.STATUS_CODE==1){
	          	if(res.PRIZE_LIST.length<10){
	          		this.$refs.myScroller.finishInfinite(2);
	          		this.allList=this.allList.concat(res.PRIZE_LIST);
	          		this.noData2=true;
	          	}else{
	          		this.requestCan=true;
	          		this.pages++;
	          		this.$refs.myScroller.finishInfinite();
	          		this.allList=this.allList.concat(res.PRIZE_LIST);
	          	}
	          }
	        },err=>{
	          console.log(err);
	        })
		},
		infinites(){
			if(this.requestCan){
				this.getwiningList();
			}
			
		},
		gowiningDetail(id){
			this.$router.push('/winingListDetail/'+id);
		},
		//获取微信的配置信息
	    getConfig(){
	      let timestamp,nonceStr,signature;
	      let desc='全民火拼，拼团专享优惠，超值一拼到底';
	      let title='拼团狂欢，一拼到底';
	      let imgUrl='http://121.40.78.200/pic/act/cover/20141123_pt_share_icon.jpg';
	      let urls=iosAdroidWx().urls;
	      let appid=iosAdroidWx().appid;
	      this.$fetchPost(urls,{'url' : window.location.href},{emulateJSON:true})
	      .then(res=>{
	        var data = res;
	        console.log(res);
	        // timestamp = data.timestamp;
	        // nonceStr =  data.nonceStr;
	        // signature = data.signature;
	        timestamp=data.NOW_TIME;
	        nonceStr=data.NONCESTR;
	        signature=data.SKEY;
	        // console.log(timestamp,nonceStr,signature,appId)
	        wx.config({
	            debug : false, // 开启调试模式,false调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
	            appId :appid, // 必填，公众号的唯一标识
	            timestamp : timestamp, // 必填，生成签名的时间戳
	            nonceStr : nonceStr, // 必填，生成签名的随机串
	            signature : signature,// 必填，签名，见附录1
	            jsApiList : [ 'onMenuShareTimeline', 'onMenuShareAppMessage','chooseWXPay', 'showOptionMenu' ]
	        });
	        let that=this;
	        let linkUrl=location.href;
	        wx.ready(function(){
	          // 分享给朋友
	          wx.onMenuShareAppMessage({
	            title: title,
	            desc: desc,
	            link: linkUrl,
	            imgUrl: imgUrl,
	            trigger: function (res) {
	            },
	            success: function (res) {
	            },
	            cancel: function (res) {
	            },
	            fail: function (res) {
	              alert(JSON.stringify(res));
	            }
	          }); 

	          //分享朋友圈
	          wx.onMenuShareTimeline({
	            title: title,
	            desc: desc,
	            link: linkUrl,
	            imgUrl: imgUrl,
	            trigger: function (res) {
	            },
	            success: function (res) {
	            },
	            cancel: function (res) {
	            },
	            fail: function (res) {
	              alert(JSON.stringify(res));
	            }
	          });
	        })
	      },err=>{

	      });
	    }
	},
	// 子组件
	components: {
		XHeader
	}
}
</script>
<!--当前页面的样式 -->
<style lang="less" scoped>
@import url('../../assets/css/public.less');
.winingList{
  background: #fff;
  height: 100%;
  min-height: 100%;
  .allList{
  	padding-top: 0.88rem;
  	padding: 0.88rem 0.25rem 0;
  	.listItem{
  		display: flex;
  		align-items:center;
  		height: 2.1rem;
  		.borderBFu(#DDDDDD);
  		img{
  			width: 1.7rem;
  			height: 1.5rem;
  		}
  		.winingMess{
  			text-align: left;
  			padding-left: 0.15rem;
  			h1{
  				color: #222222;
  				font-size: 0.3rem;
  				margin-bottom: 0.2rem;
  				text-overflow: ellipsis;
  				overflow: hidden;
  				white-space: nowrap;
  				width: 5.5rem;
  			}
  			p{
  				font-size: 0.26rem;
  				color: #999;
  				margin-bottom: 0.25rem;
  			}
  			.winingP{
  				font-size: 0.24rem;
  				color: #F22E2E;
  			}
  		}
  	}
  }
  .noMoreDate{
    position: relative;
    height: 0.6rem;
    margin-bottom:-1rem;
    z-index: 999;
    padding-top: 0.6rem;
    .noMoreLine{
      width: 2.9rem;
      margin: 0 auto;
      height: 0.02rem;
      background: #777;
      transform:scaleY(0.5);
    }
    span{
      font-size: 0.22rem;
      color: #666;
      padding: 0 0.15rem;
      position: absolute;
      background: #fff;
      transform:translate(-50%,-50%);
    }
    .noMoreList{
      background: #fff!important;
    }
  }
  .wx{
    width: 0.33rem;
    height: 0.34rem;
  }
}
</style>